package com.yanqu.road.server.cmd.orewar;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.activity.eActivityOreWarType;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.orewar.OreWarActivityMgr;
import com.yanqu.road.server.manger.activity.orewar.OreWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

//整个盐场的战斗记录
@Cmd(code = Protocol.S_ORE_WAR_NOTICE, desc = "矿战战斗通告")
public class OreWarNoticeCmd extends AbstractCommand {

	private int activityId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		OreWarProto.OreGetNoticeReqMsg reqMsg = OreWarProto.OreGetNoticeReqMsg.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ActivityInfo activityInfo = OreWarActivityMgr.getOpenActivityInfo(activityId);
		if(null != activityInfo){
			if(activityInfo.getChildType() == eActivityOreWarType.OreWar.getChildType()){
				player.sendPacket(Protocol.U_ORE_WAR_NOTICE, OreWarMgr.getUserOreWarNotice(activityId,player));
			}else if(activityInfo.getChildType() == eActivityOreWarType.CrossOreWar.getChildType()){
				player.sendPacket(Protocol.U_ORE_WAR_NOTICE, OreWarMgr.getCrossUserOreWarNotice(activityId,player));
			}
		}else{
			player.sendPacket(Protocol.U_ORE_WAR_NOTICE, OreWarProto.OreWarNoticeListMsg.newBuilder());
		}
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
